﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;
using System.Data.SqlClient;
using ECONTACT.Controller;

namespace ECONTACT
{
    public partial class frmHocKy : Form
    {
        HocKyCtrl m_HocKyCtrl = new HocKyCtrl();

        public frmHocKy()
        {
            InitializeComponent();
        }

        private void frmHocKy_Load(object sender, EventArgs e)
        {
            m_HocKyCtrl.HienThi(dGVHocKy,txtMaHK,txtTenHocKy);
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            m_HocKyCtrl.LuuHocKy(txtTenHocKy.Text);
            m_HocKyCtrl.HienThi(dGVHocKy, txtMaHK, txtTenHocKy);
        }

        private void btnCapNhat_Click(object sender, EventArgs e)
        {
            m_HocKyCtrl.UpdateHocKy(txtMaHK.Text, txtTenHocKy.Text);
            m_HocKyCtrl.HienThi(dGVHocKy, txtMaHK, txtTenHocKy);
        }

        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (dGVHocKy.RowCount == 0)
            {
                MessageBox.Show("Bạn chưa chọn dòng nào làm sao xóa!", "Thông báo");
            }
            else if (MessageBoxEx.Show("Bạn có chắc là xóa thiệt hok ?", "DELETE", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                m_HocKyCtrl.DeleteHocKy(txtMaHK.Text);
                m_HocKyCtrl.HienThi(dGVHocKy, txtMaHK, txtTenHocKy);
            }
        }
    }
}
